<?php
include("../../share/config.php");
include("../../share/lock.php");
$d = date("Y-m-d");
$yd = date("d")-1;
$ym = date("Y-m-").$yd;
$td = date("d")+1;
$tm = date("Y-m-").$td;
$count = 0;
$sql="SELECT * from cr ORDER BY da DESC";
for($i=1;$i<6;$i++){
$sql="SELECT * from cr where building = '$i' AND (da = '$d' OR da = '$ym' OR da = '$tm') ORDER BY da DESC";
echo "<h3>教".$i."楼</h3>";
echo '<div class="tab-pane active">';
			echo '
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
						<th>
							教学楼
						</th>
						<th>
							教室编号
						</th>
						<th>
							预约日期
						</th>
						<th>
							预约时段
						</th>
						<th>
							预约事由
						</th>
						<th>
							预约状态
						</th>
					</tr>
				</thead>
				<tbody>';
$result=mysqli_query($conn,$sql);
;
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
	if($row["sta"]==1){
		echo '<tr class="success">';
}
	elseif($row["sta"]==2){
		echo '<tr class="warning">';
}
	else{
		echo '<tr>';
}
	echo "<td>教".$row["building"]."楼</td>";
	echo "<td>".$row["cr_id"]."</td>";
	echo "<td>".$row["da"]."</td>";
	echo "<td>".$row["s_time"]."点-".$row["e_time"]."点</td>";
	if($row["reason"]==""){
		echo "<td>管理员操作";
	}
	else{
		echo "<td>";
		echo $row["reason"];
	}echo "</td>";
	if($row["sta"]==1){
		if($row["da"]<$d){
			echo '<td>通过：已过期</td>';
		}
		else{
			echo '<td>通过：未执行';
		}
}
	elseif($row["sta"]==2){
		echo '<td>未通过：请重新预约</td>';
}
	else{
		if($row["da"]<$d){
			echo '<td>未审核：已过期</td>';
		}
		else{
			echo '<td>未审核：<a href="../../actions/admin/accept.php?id='.$row["id"].'">通过预约</a>或<a href="../../actions/admin/cancel.php?id='.$row["id"].'">拒绝预约</td>';
		}
}
	echo "</td></tr>";
}
echo "</tbody></table></div>";
}

echo "</br></br></br></br>";
?> 